package com.yisoo.ubag.product.controller;


import com.yisoo.common.utils.PageUtils;
import com.yisoo.common.utils.R;
import com.yisoo.ubag.product.service.BrandService;
import com.yisoo.ubag.product.service.ConsumerService;
import com.yisoo.ubag.product.service.DevService;
import com.yisoo.ubag.product.service.SceneService;
import com.yisoo.ubag.product.vo.IndexDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.function.Consumer;

@RestController
@RequestMapping("product/other")
public class OtherController {

    @Autowired
    DevService devService;
    @Autowired
    BrandService brandService;
    @Autowired
    SceneService sceneService;
    @Autowired
    ConsumerService consumerService;

    @RequestMapping("/refresh/index/{userid}")
    public R refresh(@PathVariable("userid")Long userid){
        IndexDataVo indexDataVo = new IndexDataVo();
        indexDataVo.setUserName(consumerService.getById(userid).getUsername());
        indexDataVo.setBrandNum(brandService.getNumByParentId(userid));
        indexDataVo.setSceneNum(sceneService.getNumByParentId(userid));
        indexDataVo.setDevNum(devService.getNumByParentId(userid));

        indexDataVo.setFreeDevNum(100-indexDataVo.getDevNum());
        //TODO 这两个数据需要远程调用，先随便写两个
        indexDataVo.setUserNum(34* indexDataVo.getBrandNum());
        indexDataVo.setOrderNum(120* indexDataVo.getSceneNum());
//        System.out.println(userid);
        return R.ok().put("data",indexDataVo);
    }


}
